import request from '@/utils/request'

// 获取新闻列表
export function getNews(params) {
  return request({
    url: '/news/list',
    method: 'get',
    params
  })
}

// 获取新闻详情
export function getNewsDetail(id) {
  return request({
    url: `/news/${id}`,
    method: 'get'
  })
}

// 创建新闻
export function createNews(data) {
  return request({
    url: '/news',
    method: 'post',
    data
  })
}

// 更新新闻
export function updateNews(data) {
  return request({
    url: `/news/${data.id}`,
    method: 'put',
    data
  })
}

// 删除新闻
export function deleteNews(id) {
  return request({
    url: `/news/${id}`,
    method: 'delete'
  })
}

// 更新新闻状态
export function updateNewsStatus(id, status) {
  return request({
    url: `/news/${id}/status`,
    method: 'put',
    data: { status }
  })
}
